<script src="<?php echo base_url()?>js/jquery.min.js" type="text/javascript"></script>
 <script src="<?php echo base_url()?>js/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready( function() {
        $(function() {
            $('#loading').ajaxStart(function(){
                $(this).fadeIn();
            }).ajaxStop(function(){
                $(this).fadeOut();
            });
        var w = parseInt($('#week_count3').val());
        for(var a=0;a<=w;a++){
            $('#click_cmb3'+a).click(function(){
//alert(a);
                if ($("#container5").is(":hidden")) {
                    $("#container5").slideDown("slow");
                    //$('#click').text('Tutup');
                } else {
                    $("#container5").slideUp("slow");

                }
            });
        }
        $('#menu3 a').click(function() {
            var url = $(this).attr('href');
            $('#container5').load(url);
            return false;
        });


         var w = parseInt($('#week_count3').val());
        for(var a=0;a<=w;a++){
            $('#click_cmb4'+a).click(function(){
//alert(a);
                if ($("#container6").is(":hidden")) {
                    $("#container6").slideDown("slow");
                    //$('#click').text('Tutup');
                } else {
                    $("#container6").slideUp("slow");

                }
            });
        }
        $('#menu4 a').click(function() {
            var url = $(this).attr('href');
            $('#container6').load(url);
            return false;
        });

         var w = parseInt($('#week_count3').val());
        for(var a=0;a<=w;a++){
            $('#click_cmb5'+a).click(function(){
//alert(a);
                if ($("#container7").is(":hidden")) {
                    $("#container7").slideDown("slow");
                    //$('#click').text('Tutup');
                } else {
                    $("#container7").slideUp("slow");

                }
            });
        }
        $('#menu5 a').click(function() {
            var url = $(this).attr('href');
            $('#container7').load(url);
            return false;
        });

        });

    });
</script>
<?php $this->load->helper('HTML'); 
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?>
<p>&nbsp;</p>
<h2 class="title">Calon Manager Khusus Empat Bulan</h2>
<?php
$tduabulan=0;
$total_rekrutb2=0;
$total_jualrekrutb3=0;
$ttigabulan=0;
?>
<form method="post">
    <table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
        <thead>
            <?php if(isset($error)) {?>
            <tr>
                <td colspan="5">
                        <?php echo $error?>
                </td>
            </tr>
                <?php }else { ?>
            <tr  align="center" class="table" >
        <input type="hidden" id="week_count3" value="<?php echo count($weeks)?>">
        <th ><?php echo $bulan . " " . $tahun?></th>
            <?php for($i=0;$i<count($weeks);$i++):?>
        <th >Minggu Ke- <?php echo $weeks[$i]->intid_week;?></th>
            <?php endfor;?>
        <th >Total</th>

        </tr>
        </thead>
        <tbody>

            <!-- ============isi ============ -->
            <tr class='data'>
                <td>Penjualan Pribadi</td>
                    <?php
                    $total=0;
                    $total_pv=0;
					//line ikhlas 
					$count_pribadi=0;
					$non_syarat_pribadi = 0;
					$count =0;
					//end

                    for($i=0;$i<count($week_pribadi);$i++):?>
                <td align="center">
                            <?php
                            if(!empty($week_pribadi[$i][0]->total)) {
                                echo $week_pribadi[$i][0]->total;
                                $total = $total + $week_pribadi[$i][0]->total;
                                $count = $count +1;
								//untuk menghitung menjadi 4 bulan
								if($count <= 4){
									if($week_pribadi[$i][0]->total >= 250000){
										$count_pribadi = $count_pribadi + 1;
										//echo " cp: ".$count_pribadi."<br />";
									}else{
										$non_syarat_pribadi = $non_syarat_pribadi +1;
									}
								}
                            }else {
                                echo "0";
                            }
                            ?>
                </td>
                    <?php endfor;?>
                <td align="center">
                        <?php //$total = 0;
                        echo number_format($total)?>
                </td>
            </tr>

            <tr class="data">
                <td>Rekrut Baru Pribadi</td>
                    <?php
                    $total_rekrut=0;
					$count_jumlah = 0;
					
					$non_syarat_jumlah = 0;
					$count = 0;
					$cek = array();
                    for($i=0;$i<count($week_rekrut);$i++):?>
                <td align="center">
                            <?php
                            if(!empty($week_rekrut[$i][0]->total)) {
                                echo $week_rekrut[$i][0]->total;
                                $total_rekrut = $total_rekrut + $week_rekrut[$i][0]->total;
								$count = $count +1;
								if($count <= 4){
									if($week_rekrut[$i][0]->total >= 1){
										$cek[$i] = 1;
									}else{
										$cek[$i] = 0;
										$non_syarat_jumlah = $non_syarat_jumlah + 1;
									}
								}
                            }else {
                                echo "0";
								$cek[$i] = 0;
                            }
                            ?>
                </td>
                    <?php endfor;
					
						$total_cek = 0;
						for($i = 0;$i<sizeof($cek);$i++){
							$total_cek = $total_cek + $cek[$i];
							//echo "cek : ".$cek[$i];
						}
						if($total_cek >= 2){
							if($cek[0] == 0 and $cek[1] == 0 and $cek[2] == 1 and $cek[3] == 1 ){
								$count_jumlah = $count_jumlah +0;										
							}elseif($cek[0] == 1 and $cek[1] == 1 and $cek[2] == 0 and $cek[3] == 0 ){
								$count_jumlah = $count_jumlah +0;										
							}else{
								$count_jumlah = $count_jumlah +2;										
							}
						}
						//echo "count jumlah : ".$count_jumlah;
						
					?>
                <td align="center">
                        <?php echo $total_rekrut . " Orang"?>
                </td>
            </tr>
            <tr class="data">
                <td>Penjualan Rekrut</td>
                    <?php
                    $total_jualrekrut=0;
					//line ikhlas
					$count_rekrut = 0;
					$non_syarat_rekrut = 0;
					$count = 0;
					$cek = 0;
                    for($i=0;$i<count($penjualanrekrut);$i++):?>
                <td align="center">
                            <?php
                            //print_r($penjualanrekrut[$i][0]->total);
                            if(!empty($penjualanrekrut[$i])) {
                                $pr = number_format($penjualanrekrut[$i][0]->total);
                                $week = $penjualanrekrut[$i][0]->intid_week;
                                $total_jualrekrut = $total_jualrekrut + $penjualanrekrut[$i][0]->total;
								$count = $count +1;
								if($count <= 4){
									if($penjualanrekrut[$i][0]->total >= 150000){
										//$count_rekrut = $count_rekrut+1;
										$cek = $cek + 1;
										//echo " Cek : ".$cek;	
									}else{
										$non_syarat_rekrut = $non_syarat_rekrut +1;
										$cek = $cek +1;
									}
									
								}		
                                ?>
                    <div id="menu3" align="left" style="height: 40px; width: 30px">
                                    <?php  echo anchor ('calon_manager/view_rekrut4/'.$strkode."/". $week."/".$bulan_a, ($pr), array('id' =>"click_cmb3".$i));?>
                    </div>

                                <?php
                            }else {
                                $pr = "0,00";
                                $week = 0;
                                echo $pr;
                            }
                            ?>

                </td>
                    <?php endfor;
					if($cek >= 2){
						$count_rekrut = $count_rekrut+2;
						//echo " cr: ".$count_rekrut."<br />";
						$cek = 0;
						}
					?>

                <td align="center">
                          <a href="<?php echo base_url().'calon_manager/extract_pengejaran_anak_langsung?strkode_dealer='.$strkode.'&bulan='.$bulan_a;?>"><?php echo number_format($total_jualrekrut)?></a>
                </td>
            </tr>
			<?php /*
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks)?>">Total PV</td>
                <td align="center"><?php echo $week_pv->pv+ $week_pv_pribadi->pv;
					?></td>
            </tr>*/
			$total_pv = $week_pv->pv+ $week_pv_pribadi->pv;
				?>
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks)?>">Penjualan anak/cucu diluar rekrut baru</td>
                <td align="center"><?php 
				if(!empty($penjualan_luar_rekrut_total)){
					$totalpenjualan_luar_rekrut = $penjualan_luar_rekrut_total;
					}else{
							$totalpenjualan_luar_rekrut =0;
					}
					$tsatubulan = $totalpenjualan_luar_rekrut + ($total + $total_jualrekrut);
						if($tsatubulan >= 1600000) {
							$allowSave = '';
						}else {
							$allowSave = 'disabled';
						}
					$total_bener = $tsatubulan - $total - $total_jualrekrut;
				?>
				<a href="<?php echo base_url().'calon_manager/show_excelData?strkode='.$strkode.'&bulan='.$bulan_a;?>"><?php echo number_format($total_bener);?></a></td>
            </tr>
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks)?>">Total Pengejaran CM Bulan ke 1</td>
                <td align="center"><?php 
					$count_nominal = 0;
					$nominal = $total_bener + $total_jualrekrut + $total;
					if($nominal >= 3000000){
						$count_nominal = $count_nominal + 1;
					}
                        echo number_format($tsatubulan)?></td>
            </tr>

        </tbody>
            <?php } ?>
    </table>
<div id="container5" style="width:400px; height: 100px; display:none;">
		No Display Data
</div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <!-- Bulan Ke dua -->
    <table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
        <thead>
            <?php if(isset($error2)) {?>
            <tr>
                <td colspan="5">
                        <?php echo $error2?>
                </td>
            </tr>
                <?php }else { ?>
            <tr  align="center" class="table" >
        <input type="hidden" id="week_count" value="<?php echo count($weeks2)?>">
        <th ><?php echo $bulan1 . " " . $tahun?></th>
            <?php for($i=0;$i<count($weeks2);$i++):?>
        <th >Minggu Ke- <?php echo $weeks2[$i]->intid_week;?></th>
            <?php endfor;?>
        <th >Total</th>

        </tr>
        </thead>
        <tbody>

            <!-- ============isi ============ -->
            <tr class='data'>
                <td>Penjualan Pribadi</td>
                    <?php
                    $totalb2=0;
                    $total_pv2=0;
					//line ikhlas 
					$count =0;
					//$count_pribadi=0;
					$non_syarat_pribadi = 0;
					
                    for($i=0;$i<count($week_pribadi2);$i++):?>
                <td align="center">
                            <?php
                            if(!empty($week_pribadi2[$i][0]->total)) {
                                echo $week_pribadi2[$i][0]->total;
                                $totalb2 = $totalb2 + $week_pribadi2[$i][0]->total;
								/*								
								if(!empty($week_pribadi2[$i][0])){
									$total_pv1 = $total_pv1 + $week_pribadi2[$i][0]->pv;
								}
								*/
								$count = $count +1;
								//untuk menghitung menjadi 4 bulan
								if($count <= 4){
									if($week_pribadi2[$i][0]->total >= 250000){
										$count_pribadi = $count_pribadi + 1;
										//echo " Cp: ".$count_pribadi."<br />";
									}else{
										$non_syarat_pribadi = $non_syarat_pribadi +1;
									}
								}
                            }else {
                                echo "0";
                            }
                            ?>
                </td>
                    <?php endfor;?>
                <td align="center">
                        <?php //$total = 0;
                        echo number_format($totalb2)?>
                </td>
            </tr>

            <tr class="data">
                <td>Rekrut Baru Pribadi</td>
                    <?php
                    $total_rekrutb2=0;
					//line ikhlas
					//$count_rekrut = 0;
					$non_syarat_rekrut = 0;
					$count = 0;
					$cek = array();
					
					for($i=0;$i<count($week_rekrut2);$i++):?>
                <td align="center">
                            <?php
                            if(!empty($week_rekrut2[$i][0]->total)) {
                                echo $week_rekrut2[$i][0]->total;
                                $total_rekrutb2 = $total_rekrutb2 + $week_rekrut2[$i][0]->total;
								$count = $count +1;
								if($count <= 4){
									if($week_rekrut2[$i][0]->total >= 1){
										//$count_jumlah = $count_jumlah +1;
										//$cek = $cek +1;
											$cek[$i] = 1;
										}else{
											$cek[$i] = 0;
											$non_syarat_rekrut = $non_syarat_rekrut + 1;
										}
								}
							}else {
                                echo "0";
								$cek[$i] = 0;
                            }
                            ?>
                </td>
                    <?php endfor;
						$total_cek = 0;
						for($i = 0;$i<sizeof($cek);$i++){
							if($cek[$i]){
							$total_cek = $total_cek + $cek[$i];
							//echo "<br />".$i.", cek : ".$cek[$i];
							}
						}
						if($total_cek >= 2){
							if($cek[0] == 0 and $cek[1] == 0 and $cek[2] == 1 and $cek[3] == 1 ){
								$count_jumlah = $count_jumlah +0;										
							}elseif($cek[0] == 1 and $cek[1] == 1 and $cek[2] == 0 and $cek[3] == 0 ){
								$count_jumlah = $count_jumlah +0;										
							}else{
								$count_jumlah = $count_jumlah +2;										
							}
						}
				//echo "count jumlah : ".$count_jumlah;
			
										?>
                <td align="center">
                        <?php echo $total_rekrutb2 . " Orang"?>
                </td>
            </tr>
            <tr class="data">
                <td>Penjualan Rekrut</td>
                    <?php
                    $total_jualrekrutb2=0;
                    //$count_rekrut = 0;
					$non_syarat_rekrut = 0;
					$count = 0;
					$cek = 0;
                    
					for($i=0;$i<count($penjualanrekrut2);$i++):?>
                <td align="center">
                            <?php
                            //print_r($penjualanrekrut[$i][0]->total);
                            if(!empty($penjualanrekrut2[$i])) {
                                $pr = number_format($penjualanrekrut2[$i][0]->total);
                                $week = $penjualanrekrut2[$i][0]->intid_week;
                                $total_jualrekrutb2 = $total_jualrekrutb2 + $penjualanrekrut2[$i][0]->total;
                                $count = $count +1;
								if($count <= 4){
									if($penjualanrekrut2[$i][0]->total >= 150000){
										//$count_rekrut = $count_rekrut+1;
										$cek = $cek + 1;	
										
									}else{
										$non_syarat_rekrut = $non_syarat_rekrut +1;
										
									}
								}
								?>
                    <div id="menu4" style="height: 40px; width: 5px">
                                    <?php  echo anchor ('calon_manager/view_rekrut4/'.$strkode."/". $week."/".$bulan_b, ($pr), array('id' =>"click_cmb4".$i));?>
                    </div>

                                <?php
                            }else {
                                $pr = "0,00";
                                $week = 0;
                                echo $pr;
                            }
                            ?>

                </td>
                    <?php endfor;
					if($cek >= 2){
							$count_rekrut = $count_rekrut+2;
							//echo " cr :".$count_rekrut."<br />";
							$cek = 0;
							}
										?>

                <td align="center">
                        <?php //echo number_format($total_jualrekrutb2)?>
                          <a href="<?php echo base_url().'calon_manager/extract_pengejaran_anak_langsung?strkode_dealer='.$strkode.'&bulan='.$bulan_b;?>"><?php 
                        echo number_format($total_jualrekrutb2)?></a>
                        <?php $tduabulan = ($totalb2 + $total_jualrekrutb2)+$penjualan_luar_rekrut_total2; ?>
                </td>
            </tr>
			<?php /*
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks2)?>">Total PV</td>
                <td align="center"><?php echo $week_pv2->pv+ $week_pv_pribadi2->pv;
					$total_pv2 = $week_pv2->pv+ $week_pv_pribadi2->pv;
				?></td>
            </tr>
			*/ 
			$tduabulan - $totalb2 - $total_jualrekrutb2;
			?>
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks2)?>">Penjualan anak/cucu diluar rekrut baru</td>
                <td align="center"><?php
				//$nominal = $total + $total_bener +  $total_jualrekrut + $totalb2 + $total_jualrekrutb2;
				$total_bener2 = $tduabulan - $total_jualrekrutb2 - $totalb2;
				//echo $total_bener2;
				
				if(!empty($penjualan_luar_rekrut_total2)){
					$diluarb2 = $penjualan_luar_rekrut_total2;
				}else{
					$diluarb2 = 0;
				}
				 //echo number_format($diluarb2)
				 ?>
				 <a href="<?php echo base_url().'calon_manager/show_excelData?strkode='.$strkode.'&bulan='.$bulan_b;?>"><?php echo number_format($total_bener2);?></a></td>
            </tr>
            <tr class="data">
                <td>&nbsp;</td>
                <td align="center" colspan="<?php echo count($weeks2)?>">Total Pengejaran CM Bulan ke 2</td>
                <td align="center"><?php 
				$nominal = $total_bener2 + $total_jualrekrutb2 + $totalb2;
					if($nominal >= 4000000){
						$count_nominal = $count_nominal + 1;
					}
				echo number_format($tduabulan)?></td>
            </tr>
        </tbody>
            <?php } ?>
    </table>
</form>
<div id="container6" style="width:400px; height: 100px; display:none;">
		No Display Data
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>

<!-- Bulan Ke Tiga-->
<table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
    <thead>
        <?php if(isset($error3)) {?>
        <tr>
            <td colspan="5">
                    <?php echo $error3?>
            </td>
        </tr>
            <?php }else { ?>
        <tr  align="center" class="table" >
    <input type="hidden" id="week_count" value="<?php echo count($weeks3)?>">
    <th ><?php echo $bulan2 . " " . $tahun?></th>
        <?php for($i=0;$i<count($weeks3);$i++):?>
    <th >Minggu Ke- <?php echo $weeks3[$i]->intid_week;?></th>
        <?php endfor;?>
    <th >Total</th>

</tr>
</thead>
<tbody>

    <!-- ============isi ============ -->
    <tr class='data'>
        <td>Penjualan Pribadi</td>
            <?php
            $totalb3=0;
            $total_pv3=0;
			//line ikhlas 
					$count =0;
					//$count_pribadi=0;
					$non_syarat_pribadi = 0;
					
            for($i=0;$i<count($week_pribadi3);$i++):?>
        <td align="center">
                    <?php
                    if(!empty($week_pribadi3[$i][0]->total)) {
                        echo $week_pribadi3[$i][0]->total;
                        $totalb3 = $totalb3 + $week_pribadi3[$i][0]->total;
						if(!empty($week_pribadi3[$i][0]->pv)){
							$total_pv3 = $total_pv3 + $week_pribadi3[$i][0]->pv;
						}
						$count = $count +1;
								//untuk menghitung menjadi 4 bulan
						if($count <= 4){
							if($week_pribadi3[$i][0]->total >= 250000){
								$count_pribadi = $count_pribadi + 1;
								//echo " cp: ".$count_pribadi;
							}else{
								$non_syarat_pribadi = $non_syarat_pribadi +1;
								}
							}
                    }else {
                        echo "0";
                    }
                    ?>
        </td>
            <?php endfor;?>
        <td align="center">
                <?php //$total = 0;
                echo number_format($totalb3)?>
        </td>
    </tr>

    <tr class="data">
        <td>Rekrut Baru Pribadi</td>
            <?php
            $total_rekrutb3=0;
			$non_syarat_rekrut = 0;
					$count = 0;
					$cek = array( );
				for($i=0;$i<count($week_rekrut3);$i++):?>
				<td align="center">
                    <?php
					if(!empty($week_rekrut3[$i][0]->total)) {
                                echo $week_rekrut3[$i][0]->total;
                                $total_rekrutb3 = $total_rekrutb3 + $week_rekrut3[$i][0]->total;
								$count = $count +1;
								if($count <= 4){
									if($week_rekrut3[$i][0]->total >= 1){
											$cek[$i] = 1;
										}else{
											$cek[$i] = 0;
											$non_syarat_rekrut = $non_syarat_rekrut + 1;
										}
								}
							
                    }else {
						$cek[$i] = 0;
						echo "0";
                    }
                    ?>
        </td>
            <?php endfor;
			
						$total_cek = 0;
						for($i = 0;$i < sizeof($cek); $i++){
								$total_cek = $total_cek + $cek[$i];
								//echo "<br />".$i.", cek : ".$cek[$i];
						}
						if($total_cek >= 2){
							if($cek[0] == 0 and $cek[1] == 0 and $cek[2] == 1 and $cek[3] == 1 ){
								$count_jumlah = $count_jumlah +0;										
							}elseif($cek[0] == 1 and $cek[1] == 1 and $cek[2] == 0 and $cek[3] == 0 ){
								$count_jumlah = $count_jumlah +0;										
							}else{
								$count_jumlah = $count_jumlah +2;										
							}
						}
				//	echo "count jumlah : ".$count_jumlah;
			
			?>
        <td align="center">
                <?php echo $total_rekrutb3 . " Orang"?>
        </td>
    </tr>
    <tr class="data">
        <td>Penjualan Rekrut</td>
            <?php
            $total_jualrekrutb3=0;
			//$count_rekrut = 0;
					$non_syarat_rekrut = 0;
					$count = 0;
					$cek = 0;
					
            for($i=0;$i<count($penjualanrekrut3);$i++):?>
        <td align="center">
                    <?php
                    //print_r($penjualanrekrut[$i][0]->total);
                    if(!empty($penjualanrekrut3[$i])) {
                        $pr = number_format($penjualanrekrut3[$i][0]->total);
                        $week = $penjualanrekrut3[$i][0]->intid_week;
                        $total_jualrekrutb3 = $total_jualrekrutb3 + $penjualanrekrut3[$i][0]->total;
						$count = $count +1;
						if($count <= 4){
									if($penjualanrekrut3[$i][0]->total >= 150000){
										//$count_rekrut = $count_rekrut+1;
										$cek = $cek + 1;										
										
									}else{
										//$cek = $cek + 1;										
										$non_syarat_rekrut = $non_syarat_rekrut +1;
									}
								}
                        ?>
            <div id="menu5" style="height: 40px; width: 5px">
              <?php  echo anchor ('calon_manager/view_rekrut4/'.$strkode."/". $week."/".$bulan_c, ($pr), array('id' =>"click_cmb5".$i));?>
            </div>

                        <?php
                    }else {
                        $pr = "0,00";
                        $week = 0;
                        echo $pr;
                    }
                    ?>

        </td>
            <?php endfor;
			if($cek >= 2){
				$count_rekrut = $count_rekrut+2;
				//echo " cr: ".$count_rekrut."<br />";
				$cek = 0;
			}?>

        <td align="center">
                 <a href="<?php echo base_url().'calon_manager/extract_pengejaran_anak_langsung?strkode_dealer='.$strkode.'&bulan='.$bulan_c;?>"><?php
                echo number_format($total_jualrekrutb3)?></a>
                <?php $ttigabulan = ($totalb3 + $total_jualrekrutb3)+$penjualan_luar_rekrut_total3; ?>
        </td>
    </tr>
    <tr class="data">
        <td>&nbsp;</td>
        <td align="center" colspan="<?php echo count($weeks3)?>">Penjualan anak/cucu diluar rekrut baru</td>
        <td align="center"><?php 
              	$nominal = $total + $total_bener +  $total_jualrekrut + $totalb2 + $total_jualrekrutb2 + $total;
				//$total_bener3 = $ttigabulan - $total_jualrekrutb3 - $total_rekrutb3;
				$total_bener3 = $ttigabulan - $total_jualrekrutb3 - $totalb3;
				if(!empty($penjualan_luar_rekrut_total3)){
					$diluarb3 = $penjualan_luar_rekrut_total3;
				}else{
					$diluarb3 = 0;
				}
				 ?>
				 <a href="<?php echo base_url().'calon_manager/show_excelData?strkode='.$strkode.'&bulan='.$bulan_c;?>"><?php echo number_format($total_bener3);?></a></td>
    </tr>
    <tr class="data">
        <td>&nbsp;</td>
        <td align="center" colspan="<?php echo count($weeks3)?>">Total Pengejaran CM Bulan ke 3</td>
        <td align="center"><?php 
			$nominal = $total_bener3 + $total_jualrekrutb3 + $totalb3;
					if($nominal >= 5000000){
						$count_nominal = $count_nominal + 1;
					}
		echo number_format($ttigabulan)?></td>
    </tr>

</tbody>
    <?php } ?>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<!-- Bulan Ke Empat-->
<table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
    <thead>
        <?php if(isset($error4)) {?>
        <tr>
            <td colspan="5">
                    <?php echo $error4?>
            </td>
        </tr>
            <?php }else { ?>
        <tr  align="center" class="table" >
    <input type="hidden" id="week_count" value="<?php echo count($weeks4)?>">
    <th ><?php echo $bulan3 . " " . $tahun?></th>
        <?php for($i=0;$i<count($weeks4);$i++):?>
    <th >Minggu Ke- <?php echo $weeks4[$i]->intid_week;?></th>
        <?php endfor;?>
    <th >Total</th>

</tr>
</thead>
<tbody>

    <!-- ============isi ============ -->
    <tr class='data'>
        <td>Penjualan Pribadi</td>
            <?php
            $totalb4=0;
            $total_pv4=0;
			//line ikhlas 
					$count =0;
					//$count_pribadi=0;
					$non_syarat_pribadi = 0;
					
            for($i=0;$i<count($week_pribadi4);$i++):?>
        <td align="center">
                    <?php
                    if(!empty($week_pribadi4[$i][0]->total)) {
                        echo $week_pribadi4[$i][0]->total;
                        $totalb4 = $totalb4 + $week_pribadi4[$i][0]->total;
						if(!empty($week_pribadi4[$i][0]->pv)){
							$total_pv4 = $total_pv4 + $week_pribadi4[$i][0]->pv;
						}
						$count = $count +1;
								//untuk menghitung menjadi 4 bulan
						if($count <= 4){
							if($week_pribadi4[$i][0]->total >= 250000){
								$count_pribadi = $count_pribadi + 1;
								//echo " cp: ".$count_pribadi;
							}else{
								$non_syarat_pribadi = $non_syarat_pribadi +1;
								}
							}
                    }else {
                        echo "0";
                    }
                    ?>
        </td>
            <?php endfor;?>
        <td align="center">
                <?php //$total = 0;
                echo number_format($totalb4)?>
        </td>
    </tr>

    <tr class="data">
        <td>Rekrut Baru Pribadi</td>
            <?php
            $total_rekrutb4=0;
			$non_syarat_rekrut = 0;
					$count = 0;
					$cek = array( );
				for($i=0;$i<count($week_rekrut4);$i++):?>
				<td align="center">
                    <?php
					if(!empty($week_rekrut4[$i][0]->total)) {
                                echo $week_rekrut4[$i][0]->total;
                                $total_rekrutb4 = $total_rekrutb4 + $week_rekrut4[$i][0]->total;
								$count = $count +1;
								if($count <= 4){
									if($week_rekrut4[$i][0]->total >= 1){
											$cek[$i] = 1;
										}else{
											$cek[$i] = 0;
											$non_syarat_rekrut = $non_syarat_rekrut + 1;
										}
								}
							
                    }else {
						$cek[$i] = 0;
						echo "0";
                    }
                    ?>
        </td>
            <?php endfor;
			
						$total_cek = 0;
						for($i = 0;$i < sizeof($cek); $i++){
								$total_cek = $total_cek + $cek[$i];
								//echo "<br />".$i.", cek : ".$cek[$i];
						}
						if($total_cek >= 2){
							if($cek[0] == 0 and $cek[1] == 0 and $cek[2] == 1 and $cek[3] == 1 ){
								$count_jumlah = $count_jumlah +0;										
							}elseif($cek[0] == 1 and $cek[1] == 1 and $cek[2] == 0 and $cek[3] == 0 ){
								$count_jumlah = $count_jumlah +0;										
							}else{
								$count_jumlah = $count_jumlah +2;										
							}
						}
				//	echo "count jumlah : ".$count_jumlah;
			
			?>
        <td align="center">
                <?php echo $total_rekrutb4 . " Orang"?>
        </td>
    </tr>
    <tr class="data">
        <td>Penjualan Rekrut</td>
            <?php
            $total_jualrekrutb4=0;
			//$count_rekrut = 0;
					$non_syarat_rekrut = 0;
					$count = 0;
					$cek = 0;
					
            for($i=0;$i<count($penjualanrekrut4);$i++):?>
        <td align="center">
                    <?php
                    //print_r($penjualanrekrut[$i][0]->total);
                    if(!empty($penjualanrekrut4[$i])) {
                        $pr = number_format($penjualanrekrut4[$i][0]->total);
                        $week = $penjualanrekrut4[$i][0]->intid_week;
                        $total_jualrekrutb4 = $total_jualrekrutb4 + $penjualanrekrut4[$i][0]->total;
						$count = $count +1;
						if($count <= 4){
									if($penjualanrekrut4[$i][0]->total >= 150000){
										//$count_rekrut = $count_rekrut+1;
										$cek = $cek + 1;										
										
									}else{
										//$cek = $cek + 1;										
										$non_syarat_rekrut = $non_syarat_rekrut +1;
									}
								}
                        ?>
            <div id="menu5" style="height: 40px; width: 5px">
              <?php  echo anchor ('calon_manager/view_rekrut4/'.$strkode."/". $week."/".$bulan_d, ($pr), array('id' =>"click_cmb5".$i));?>
            </div>

                        <?php
                    }else {
                        $pr = "0,00";
                        $week = 0;
                        echo $pr;
                    }
                    ?>

        </td>
            <?php endfor;
			if($cek >= 2){
				$count_rekrut = $count_rekrut+2;
				//echo " cr: ".$count_rekrut."<br />";
				$cek = 0;
			}?>

        <td align="center">
                 <a href="<?php echo base_url().'calon_manager/extract_pengejaran_anak_langsung?strkode_dealer='.$strkode.'&bulan='.$bulan_d;?>"><?php
                echo number_format($total_jualrekrutb4)?></a>
                <?php $tempatbulan = ($totalb4 + $total_jualrekrutb4)+$penjualan_luar_rekrut_total4; ?>
        </td>
    </tr>
    <tr class="data">
        <td>&nbsp;</td>
        <td align="center" colspan="<?php echo count($weeks4)?>">Penjualan anak/cucu diluar rekrut baru</td>
        <td align="center"><?php 
              	$nominal = $total + $total_bener +  $total_jualrekrut + $totalb2 + $total_jualrekrutb2 + $total;
				//$total_bener3 = $ttigabulan - $total_jualrekrutb4 - $total_rekrutb4;
				$total_bener4 = $tempatbulan - $total_jualrekrutb4 - $totalb4;
				if(!empty($penjualan_luar_rekrut_total4)){
					$diluarb4 = $penjualan_luar_rekrut_total4;
				}else{
					$diluarb4 = 0;
				}
				 ?>
				 <a href="<?php echo base_url().'calon_manager/show_excelData?strkode='.$strkode.'&bulan='.$bulan_d;?>"><?php echo number_format($total_bener4);?></a></td>
    </tr>
    <tr class="data">
        <td>&nbsp;</td>
        <td align="center" colspan="<?php echo count($weeks4)?>">Total Pengejaran CM Bulan ke 4</td>
        <td align="center"><?php 
			$nominal = $total_bener4 + $total_jualrekrutb4 + $totalb4;
					if($nominal >= 5000000){
						$count_nominal = $count_nominal + 1;
					}
		echo number_format($tempatbulan)?></td>
    </tr>

</tbody>
    <?php } ?>
</table>
<div id="container7" style="width:400px; height: 100px; display:none;">
		No Display Data
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action="<?php echo $form_action?>" method="post" id="frm">
    <table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
        <tr class="data">
            <td align="center" colspan="4">Total Pengejaran CM Selama Empat Bulan</td>
            <td align="center"><?php
                $totcm3 = $tsatubulan + $tduabulan + $ttigabulan + $tempatbulan;
                echo number_format($totcm3);
                ?></td>
        </tr>
        <tr class="data">
            <td align="center" colspan="4">Rekrut Pribadi Baru</td>
            <td align="center"><?php
                $trekruttigabulan = $total_rekrutb2 + $total_rekrut + $total_rekrutb3 +  $total_rekrutb4;
                echo ($trekruttigabulan). " Orang";

                ?></td>
        </tr>
        <?php
		//echo "total_pv".$total_pv."<br />";
		//echo "total_pv2".$total_pv2."<br />";
		//echo "total_pv3".$total_pv3."<br />";
        $totpv = $total_pv + $total_pv2 + $total_pv3+$total_pv4;
        //if(($trekruttigabulan >= 6)&&($totcm3 >= 12000000)) {
		//echo "count_rekrut : ".$count_rekrut."<br/>";
	///	echo "count_jumlah : ".$count_jumlah."<br/>";
		//echo "count_pribadi : ".$count_pribadi."<br/>";
		if($count_rekrut == 6 and $count_jumlah == 6 and $count_pribadi == 12 and $count_nominal == 3 and $id_cabang == 1){
            ?>
        <tr>
            <td colspan="5" align="left">
			<?php
			//echo "strkode_dealer : ".$strkode."<br/>";
			//echo "khusus : ".$khusus."<br/>";
			//echo "totcm3 : ".$totcm3."<br/>";
			//echo "total_pv : ".$totpv."<br/>";
			?>
                <input type="hidden" name="strkode_dealer"  id="strkode_dealer" value="<?php echo $strkode?>">
                <input type="hidden" name="khusus"  id="khusus" value="<?php echo $khusus?>">
                <input type="hidden" name="total_omset"  id="total_omset" value="<?php echo $totcm3?>">
                <input type="hidden" name="total_pv"  id="total_pv" value="<?php echo $totpv?>">

                <input type="submit" name="simpan" id="submit4" value="simpan"></td>
            <td colspan="2" align="center"></td>
        </tr>
            <?php }else { ?>
        <form method="post" action="<?php echo $form_action;?>">
    	<table id="data">
        <tr>
            <td>Tidak Memenuhi Syarat ! Belum bisa Melanjutkan ke Calon Manager Berikutnya</td>
            <td>
                <input type="hidden" name="strkode_dealer"  id="strkode_dealer" value="<?php echo $strkode?>">
                <input type="submit" name="submit" value="Reset Pra Cm"> </td>
        </tr>
    </table>
</form>

            <?php
        }
        ?>
    </table>
</form>
<div id="message4"></div>
<script type="text/javascript">
        $(document).ready( function() {
            $("#rec1").dialog({
                autoOpen: false,
                modal: true,
                width: '300'
            });
            $('#submit4').click(function() {


                var form_data = {
                    strkode_dealer : $('#strkode_dealer').val(),
                    khusus : $('#khusus').val(),
                    total_omset : $('#total_omset').val(),
                    total_pv : $('#total_pv').val(),
                    ajax : '1'
                };
                $.ajax({
                    url: "<?php echo base_url(); ?>calon_manager/last_selection",
                    type: 'POST',
                    async : false,
                    data: form_data,
                    success: function(msg) {
                        $('#message4').html(msg);
                    }
                });
                return false;
            });
        });
</script>